package org.csu.jpetstore_front.controller.front;


import org.csu.jpetstore_front.common.CommonResponse;

import org.csu.jpetstore_front.node.PassToken;
import org.csu.jpetstore_front.service.ItemService;
import org.csu.jpetstore_front.vo.SearchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/items")
@CrossOrigin
public class ItemController {

    @Autowired
    private ItemService itemService;


    //此处keyword是productName
    @ResponseBody
    @GetMapping("/search")
    @PassToken
    public CommonResponse<List<SearchVO>> searchByKeyword(String keyWord) {
        return itemService.searchByKeyword(keyWord);
    }
}
